package utils.db.impl;

import java.sql.SQLException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import utils.db.api.IEditUser;

public class EditUser extends DBOperation implements IEditUser{
	private static Logger logger = LoggerFactory.getLogger(EditUser.class);

	public EditUser(){
		super();
	}
	
	
	@Override
	public void changeType(int id, String type) {
		try{
			 initializeEditTypeStatement(id,type);
		}catch(Exception e){
			logger.error("Error during edit user");
		}
		
	}
	@Override
	public void deleteUser(int id) {
		try{
			 initializeDeleteUserStatement(id);
		}catch(Exception e){
			logger.error("Error during delete user");
		}
	}
	
	private void initializeEditTypeStatement(int id,String type)
			throws SQLException {
		pstmt = super.getConnector().prepareStatement(CHANGE_TYPE);
		pstmt.setString(1, type);
		pstmt.setInt(2, id);
		pstmt.execute();
		pstmt.close();
	}
	
	private void initializeDeleteUserStatement(int id)
			throws SQLException {
		pstmt = super.getConnector().prepareStatement(DELETE_USER);
		pstmt.setInt(1, id);
		pstmt.execute();
		pstmt.close();
	}
}
